[Serve] Skip routing stats collection for deployments without record_routing_stats#60810
Open
abrarsheikh wants to merge 3 commits intomasterfrom
Open
[Serve] Skip routing stats collection for deployments without record_routing_stats#60810abrarsheikh wants to merge 3 commits intomasterfrom
record_routing_stats#60810abrarsheikh wants to merge 3 commits intomasterfrom
Conversation
Signed-off-by: abrar <abrar@anyscale.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable optimization by skipping routing stats collection for deployments that don't define the record_routing_stats method. The implementation is clear and the test updates are appropriate. I've included a few suggestions to enhance maintainability, primarily by refactoring the ReplicaMetadata tuple into a dataclass to make the code more robust against future modifications. I also noted a minor redundancy that could be simplified. Overall, this is a solid improvement.
Comment on lines
+1077
to
+1080
| has_user_routing_stats_method = ( | ||
| self._user_callable_wrapper is not None | ||
| and self._user_callable_wrapper.has_user_routing_stats_method | ||
| ) |
Contributor
There was a problem hiding this comment.
| for replica in deployment_dict[id]: | ||
| ref = replica.get_actor_handle().initialize_and_get_metadata.remote() | ||
| _, version, _, _, _, _, _, _, _, _ = ray.get(ref) | ||
| _, version, _, _, _, _, _, _, _, _, _ = ray.get(ref) |
Contributor
| actor_handle = ray.get_actor(replica_name, namespace=SERVE_NAMESPACE) | ||
| ref = actor_handle.initialize_and_get_metadata.remote() | ||
| _, version, _, _, _, _, _, _, _, _ = ray.get(ref) | ||
| _, version, _, _, _, _, _, _, _, _, _ = ray.get(ref) |
Contributor
eicherseiji
approved these changes
Feb 6, 2026
Contributor
eicherseiji
left a comment
There was a problem hiding this comment.
Propagates _user_record_routing_stats presence info to ActorReplicaWrapper so _should_record_routing_stats can return early
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
record_routing_stats.remote()calls to every replica, even when the user hadn't defined arecord_routing_statsmethod on their deployment class. In that case, the remote call simply returns{}, making it pure overhead.has_user_routing_stats_methodboolean toReplicaMetadata, reported during replica initialization. The controller uses this to skip the remote call entirely when the method is absent.Test plan
test_deployment_state.py-- 102 unit tests passtest_controller_recovery.py::test_recover_start_from_replica_actor_names-- 2 tests passtest_metrics.py::test_routing_stats_delay_metric-- updated to definerecord_routing_statson test deploymenttest_metrics.py::test_routing_stats_error_metric-- no changes needed (already defines the method)related to #60680